<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #div1{
          width:200px; height:200px; background:red; position:relative;
        }
        #div2{
            width:100px; height:100px; background:#ccc; position:absolute; top:50px; left:50px;
        }
    </style>
    <script>
        window.onload=function(){
          var oDiv2=document.getElementById('div2');
          alert(oDiv2.offsetParent);
        };
    </script>
</head>
<body>
<div id="div1">
    <div id="div2"></div>
</div>
</body>
</html>